<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.homework.*"%>
<%@ page import="net.sf.json.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("UTF-8");
String userno=session.getAttribute("userno").toString();
String status=request.getParameter("status");
System.out.print(status);

List<Map> jlist=new ArrayList<Map> ();
if(status==null||status.equals("all")){
   jlist=Homework.getorderedhomeworks(userno);
}
else if(status.equals("already")){

  jlist=Homework.getorderedhomeworks(userno,'1');
}
else{
jlist=Homework.getorderedhomeworks(userno,'0');
}
    	
    	//System.out.println(jlist.size());
    	JSONArray json = new JSONArray(); 
    	 for(int i=0;i<jlist.size();i++){
    		 Map map=jlist.get(i);
    		Homework work=new Homework();   		    		
    		 JSONObject j=new JSONObject();
    		 j.put("taskid",map.get("taskid"));
    		 j.put("taskname", map.get("taskname"));
    		 j.put("name", map.get("name"));
              j.put("detail", "作业详情");    		     		 
    		 j.put("endtime",(map.get("endtime")).toString());	
    		 j.put("status",  ((map.get("status").equals("1")?"完成":"未完成") )); 	     		   		 
    		 j.put("isappend",((map.get("isappend").equals("1")?"有附件":"无") ));
    		 json.add(j);
    	 }
    	//System.out.println(json);
out.println(json);

 %>
